import Vue from 'vue'
import Vuex from 'vuex'
import cart from './modules/cart'
import production from './modules/production'

Vue.use(Vuex)

const myPlugin = store => {
  store.subscribe((mutation, state) => {
    if (mutation.type.startsWith('cart')) {
      window.localStorage.setItem('cart-productions', JSON.stringify(state.cart.productions))
    }
  })
}

export default new Vuex.Store({
  state: {
  },
  mutations: {
  },
  actions: {
  },
  modules: {
    cart,
    production
  },
  plugins: [myPlugin]
})
